﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeVisual
{
    enum NodeType { ClsNode, FuncNode, VarNode };


    abstract class myTreeNode
    {
        protected NodeType _tp;

        public NodeType tp
        {
            get { return _tp; }
        }

        public string name = null;
    }


    /// <summary>
    /// Trieda reprezentujuca triedy v zdrojovych kodoch
    /// </summary>
    class ClassNode : myTreeNode
    {
        public ClassNode(string name)
        {
            this._tp = NodeType.ClsNode;
            this.name = name;
        }
    }



    /// <summary>
    /// Trieda reprezentujuca funkcie v zdrojovych kodoch
    /// </summary>
    class FunctionNode : myTreeNode
    {
        public int callNum;
        public Dictionary<String, int> funcCall;
        public Dictionary<String, Variable> vars;

        public FunctionNode()
        {
            vars = new Dictionary<string, Variable>();
            funcCall = new Dictionary<string, int>();
            callNum = 0;
        }

    }

    /// <summary>
    /// Struktura reprezentujuca premenne v zdrojovych kodoch
    /// </summary>
    struct Variable
    {
        private string Name;
        public string name
        {
            get { return Name; }
            set { Name = value; }
        }

        // Modifikacia premenne
        VarChange vc;


        public Variable(string Name)
        {
            this.Name = Name;
            vc = new VarChange(0, 0, 0);
        }

        public void Read()
        {
            vc.Read();
        }

        public void Write()
        {
            vc.Write();
        }

        public void Modify()
        {
            vc.Modify();
        }
    }

    /// <summary>
    /// Struktura reprezentujuca zmenu premennych
    /// </summary>
    struct VarChange
    {
        public int read;
        public int write;
        public int modif;

        public VarChange(int r, int w, int m)
        {
            read = r;
            write = w;
            modif = m;
        }

        public void Read()
        {
            this.read++;
        }
        public void Write()
        {
            this.write++;
        }

        public void Modify()
        {
            this.modif++;
        }
    }

    
}
